#pragma once
#include "gameroom.h"

class GameMissionRoom : public GameRoom
{
public:
	GameMissionRoom(void);
	virtual ~GameMissionRoom(void);

	VOID Init( KEYTYPE Key, CODETYPE MapCode, const TCHAR * pszRoomTitle, const TCHAR * pszRoomPWD, const BASE_ROOMINFO * IN pRoomInfo );

	virtual eZONETYPE	GetZoneType() { return eZONETYPE_MISSION;	}

	virtual VOID		Ready( Player * pPlayer, CODETYPE FieldCode, WzID AreaID );
	virtual BOOL		Join( Player * pPlayer, CODETYPE FieldCode, WzID AreaID );

private:
	__DECL_GAMEZONEPOOL(GameMissionRoom)
};

class Trigger;
template< class PACKET>
class SendActionDoneTriggers
{
	PACKET m_msg;
public:
	SendActionDoneTriggers(){ m_msg.m_byCount = 0; }
	~SendActionDoneTriggers(){}

	BOOL SendInfo( Player * pPlayer )
	{
		if( m_msg.m_byCount != 0 )
			return pPlayer->SendPacket( &m_msg, m_msg.GetSize() );
		return TRUE;
	}
	void operator()( Trigger * pTrigger )
	{
		if( pTrigger->GetTriggerState() == Trigger::TERMINATING_STATE )
		{
			ASSERT( m_msg.m_byCount < PACKET::MAX_DONE_TRIGGER_ID_NUM );
			if( m_msg.m_byCount >= PACKET::MAX_DONE_TRIGGER_ID_NUM ) return;
			m_msg.m_dwDoneTriggerID[m_msg.m_byCount++] = pTrigger->TriggerID();
		}
	}
};
